﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SearchMetricsModel>" %>
<%@ Import Namespace="eCRAM.Tools" %>
<%@ Import Namespace="eCRAM.WebSite.Models" %>
<%@ Import Namespace="eCRAM.WebSite.Tools" %>
<%@ Import Namespace="System.Globalization" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
     <h2>Métriques</h2>
    <fieldset>
        <legend>
            Filtres</legend>
        <%
            using(Html.BeginForm("Search","ProjectResume"))
            {
               %> 
                <%= Html.LabelFor(model => model.Criterias.ActivityId)%> 
                <%= Html.DropDownListFor(model => model.Criterias.ActivityId, ViewData.GetRestrictedActivityList(SessionTools.User.Id).AddEmptyListItem())%>
                
                <input type="submit" value="Rechercher" />
                
            <%}%>
              
    </fieldset>        
    <%
              if(Model.Results != null)
              {
                  using(Html.BeginForm("Search","ProjectResume", FormMethod.Post,new { Id = "formResults"}))
                  { %>

                    <fieldset>
                    <legend>
                            Resultats</legend>

                    <table>
                        <tr>
                         <td>Nom :</td><td><%=Html.Encode(Model.Results.Name)%></td>
                        </tr>
                        <tr>
                         <td>Date début :</td><td><%=Html.Encode(Model.Results.StartDate.ToShortDateString())%></td>
                        </tr>
                        <tr>
                         <td>Date fin :</td><td><%=Html.Encode(Model.Results.EndDate.HasValue ? Model.Results.EndDate.Value.ToShortDateString() : String.Empty)%></td>
                        </tr>
                        <tr>
                         <td>Type :</td><td><%=Html.Encode(Model.Results.TypeActivityLabel)%></td>
                        </tr>
                        <tr>
                         <td>Actif :</td><td><%=Html.Encode(Model.Results.IsActive ? "Oui" : "Non")%></td>
                        </tr>
                        <tr>
                         <td>Chef de projet:</td><td><%=Html.Encode(Model.Results.ProjectLeader)%></td>
                        </tr>
                     </table>

                    <fieldset>
                    <legend>Nombre de Cram par mois</legend>
                    <%
                        foreach (var item in Model.Results.CramsByActivity)
                        {
                            var dateTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;
                            string monthNames = dateTimeFormat.MonthNames[item.Month - 1].Capitalize();
                            Response.Write(string.Format("<p>{0}  {1}   :  {2} </p>", monthNames, item.Year, item.NbCrams));
                            //Html.Encode(string.Format("{0}  {1}   :  {2}", month_names, item.Year,
                            //                          item.nbCrams));
                        }
                    %>
                    </fieldset>
                    
                     <fieldset>
                    <legend>Jours travaillés par utilisateur</legend>
                    <%
                        foreach (var item in Model.Results.CramsByUser)
                        {
                            Response.Write(string.Format("<p>{0} {1}   :  {2} </p>", item.User.LastName.ToUpper(), item.User.FirstName, item.Total.ToString("0.#")));
                          
                        }
                    %>
                    </fieldset> 

                     <fieldset>
                    <legend>Récapitulatif par statut</legend>
                    <%
                        foreach (var item in Model.Results.CramsByStatus)
                        {
                            Response.Write(string.Format("<p>{0}    :  {1} </p>",item.Status, item.Total));
                        }
                    %>
                    </fieldset> 
        <%              
                  }
              }
              
                      
             %>
    </fieldset>
   
    
    </asp:Content>
